package com.zbl.controller;

import com.zbl.parser.TableJsoupParse;
import com.zbl.service.MultiPageCrawlerService;
import com.zbl.vo.WrapperRequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @Author: zhangjun
 * @Date: 2020/7/29 14:23
 * @Description: 多页数据爬取
 */
@RestController
@RequestMapping("/multi/page")
public class MultiPageCrawlerController {
    @Resource
    private MultiPageCrawlerService crawlerService;

    @RequestMapping("/craw")
    public String craw() throws IOException {

        //方式一：
//        crawlerService.recursionCrawler("https://www.qb5.tw/shu/114543/46393387.html");
//        crawlerService.recursionCrawler("https://www.17k.com/chapter/3174071/40713246.html");

        //方式二：
        /*for (int i=1;i<=5;i++) {
            System.out.println(">>>>>>>>>>>>>> 第 " + i + " 页数据 <<<<<<<<<<<<<<<");
            crawlerService.webClintCrawlerData("https://auction.rmfysszc.gov.cn/Result.aspx?page=" + i + "&size=15&name=&status=");
        }*/

        //方式三：
        WrapperRequestParam param = new WrapperRequestParam();
        param.setUrl("https://www.imooc.com/course/list");
        crawlerService.webClintCrawlerDataParseWithJSoup(param, new TableJsoupParse());
        return "ok";
    }

}
